/**
 * 
 */
package langnstats.project.languagemodel.srilm;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import langnstats.project.lib.WordType;
/**
 * 
 * Here we use a complete flat structure
 * 
 * @author qing
 *
 */
public class NGram implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 8306329537351201729L;
	// The order
	private int order;
	// The current word id;
	private int wid;
	// The history NGram
	private NGram history = null;
	// The children ngrams
	private Map<String, NGram> children = new HashMap<String,NGram>();
	// The probability, and discount
	private double prob, disc;
	
	public NGram getChildNGram(String t){
		return children.get(t);
	}
	
	/**
	 * Input the probability and discount
	 * @param t
	 * @param prob
	 * @param disc
	 * @return
	 */
	public NGram putChildNGram(String t, double prob, double disc){
		NGram n = new NGram();
		n.prob = prob;
		n.disc = disc;
		n.order = order + 1;
		n.history = this;
		//n.wid = t.getIndex();
		children.put(t, n);
		return n;
	}
	public double getDisc() {
		return disc;
	}
	public void setDisc(double disc) {
		this.disc = disc;
	}
	public NGram getHistory() {
		return history;
	}
	public void setHistory(NGram history) {
		this.history = history;
	}
	public int getOrder() {
		return order;
	}
	public void setOrder(int order) {
		this.order = order;
	}
	public double getProb() {
		return prob;
	}
	public void setProb(double prob) {
		this.prob = prob;
	}
	public int getWid() {
		return wid;
	}
	public void setWid(int wid) {
		this.wid = wid;
	}
	
	
	
}
